package org.manon.json.meta;

import java.lang.reflect.Method;


/**
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 */
public abstract class MetaProperty implements Comparable<MetaProperty> {

	private final MetaPropertyType _type;
	private final String _name;
	private final String _label;
	private final Class<?> _returnType;
	

	protected MetaProperty(MetaPropertyType type,String name,String label,Method method) {
		this(type,name,label,method.getReturnType());
	}
	
	protected MetaProperty(MetaPropertyType type,String name,String label,Class<?> clazz) {
		_type = type;
		_name = name;
		_label = label;
		_returnType = clazz;
	}

	public String getName() {
		return _name;
	}

	public String getLabel() {
		return _label;
	}

	public Class<?> getReturnType() {
		return _returnType;
	}

	public MetaPropertyType getType() {
		return _type;
	}

	public String toString(StringBuilder builder) {
		builder.append("type=[").append(_type).append("], name=[");
		builder.append(_name).append("], label=[")
				.append(_label).append("], returnType=[").append(_returnType).append("]");
		return builder.toString();
	}

	public abstract void accept(MetaPropertyVisitor visitor);
}